﻿
@{
    ViewBag.Title = "商家信息";
}
@section CSS{
    <link href="~/Content/css/layerui/layui.css" rel="stylesheet" />
}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <section class="content-header">
        <h1>
            @ViewBag.text
            <small>商家</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">系统设置</a></li>
            <li class="active">商家信息</li>
        </ol>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-body">
                        <div class="ibox float-e-margins">

                            <div class="ibox float-e-margins">
                                <div class="ibox-content">
                                    @if (Model != null)
                                    {
                                        <form class="form-horizontal" id="from-add" novalidate="novalidate" method="post" action="/shop/AddorEditCompanyInfo">

                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">公司名称：</label>
                                                <div class="col-sm-9">
                                                    <span class="help-block m-b-none">@Model.company_name</span>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">社会信用代码：</label>
                                                <div class="col-sm-9">
                                                    <span class="help-block m-b-none">@Model.organizing_bar</span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">公司地址：</label>
                                                <div class="col-sm-9">
                                                    <span class="help-block m-b-none">@Model.address</span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">营业执照有效期：</label>
                                                <div class="col-sm-9">
                                                    <span class="help-block m-b-none">@(Model.expiry_date)</span>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">营业执照：</label>
                                                <div class="col-sm-3">
                                                    <div class="layui-upload">
                                                        <div class="layui-upload-list">
                                                            <img class="layui-upload-img" id="business_llicence_img" onclick="javascript:imgzoom(this.id)" style="width: 150px; height: 150px; cursor: pointer">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">法人身份证信息：</label>
                                                <div class="col-sm-3">
                                                    <div class="layui-upload">
                                                        <div class="layui-upload-list">
                                                            <img class="layui-upload-img" id="face_card_img" onclick="javascript:imgzoom(this.id)" style="width: 150px; height: 150px; cursor: pointer">
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="col-sm-3">
                                                    <div class="layui-upload">
                                                        <div class="layui-upload-list">
                                                            <img class="layui-upload-img" id="opposite_card_img" onclick="javascript:imgzoom(this.id)" style="width: 150px; height: 150px; cursor: pointer">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">法人姓名：</label>
                                                <div class="col-sm-9">
                                                    <span class="help-block m-b-none">@Model.corporation</span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">法人电话：</label>
                                                <div class="col-sm-9">
                                                    <span class="help-block m-b-none">@Model.corporation_phone</span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">法人身份有效期：</label>
                                                <div class="col-sm-9">
                                                    <span class="help-block m-b-none">@(Model.card_date )</span>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">联系人姓名：</label>
                                                <div class="col-sm-9">
                                                    <span class="help-block m-b-none">@Model.real_name</span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">联系人电话：</label>
                                                <div class="col-sm-9">
                                                    <span class="help-block m-b-none">@Model.wordtel</span>
                                                </div>
                                            </div>
                                            <div class="hr-line-dashed"></div>

                                            <input type="hidden" id="id" value="0" name="id">
                                            <input type="hidden" id="opposite_card" value="" name="opposite_card">
                                            <input type="hidden" id="business_llicence" value="" name="business_llicence">
                                            <input type="hidden" id="face_card" value="" name="face_card">
                                            <input type="hidden" id="province" value="0" name="province">
                                            <input type="hidden" id="city" value="0" name="city">
                                            <input type="hidden" id="country" value="0" name="country">
                                        </form>
                                    }
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

</div>

@section JS{
    <script src="~/Content/js/jquery.form.js"></script>
    <script src="~/Content/plugins/validate/jquery.validate.min.js"></script>
    <script src="~/Content/plugins/validate/messages_zh.min.js"></script>

    <script type="text/javascript">
        var _id = "@ViewBag.id";
        $(function () {
            if (_id != undefined && _id!="0")
            {
                //getinfo(_id);
                var business_llicence = '@(Model==null?"": Model.business_llicence)';
                var face_card = '@(Model==null?"": Model.face_card)';
                var opposite_card = '@(Model==null?"": Model.opposite_card)';
                    if (business_llicence != "") {
                        $("#business_llicence_img").attr('src', domain + business_llicence);
                    }
                    if (face_card != "") {
                        $("#face_card_img").attr('src', domain + face_card);
                    }
                    if (opposite_card != "") {
                        $("#opposite_card_img").attr('src', domain + opposite_card);
                    }
            }
            else{
                layer.alert('信息获取失败，请重试！', { icon: 5 });
             }
        });

        function getinfo(_id) {
            ajax("/Setting/GetCompanyInfo/" + _id, {}, function (data) {
                if (data!= null) {
                    $("#id").val(data.id);
                    $("#company_name").val(data.company_name);
                    $("#organizing_bar").val(data.organizing_bar);
                    $("#expiry_date").val(data.expiry_date);
                    $("#address").val(data.address);
                    $("#corporation").val(data.corporation);
                    $("#corporation_phone").val(data.corporation_phone);
                    $("#business_llicence_img").attr('src', domain+data.business_llicence);
                    $("#face_card_img").attr('src', domain+data.face_card);
                    $("#opposite_card_img").attr('src', domain+data.opposite_card);
                    $("#business_llicence").val(data.business_llicence);
                    $("#face_card").val(data.face_card);
                    $("#opposite_card").val(data.opposite_card);
                    //获取省市城市列表
                    //getprovince(0, "#selProvice", data.province);
                    //getprovince(data.province, "#selCity", data.city);
                    //getprovince(data.city, "#selCounty", data.country);
                    //$("#country").val(data.country);
                    //$("#city").val(data.area);
                    //$("#country").val(data.country);

                    $("#card_date").val(data.card_date);
                    $("#real_name").val(data.real_name);
                    $("#wordtel").val(data.wordtel);
                    //公司唯一，禁止修改
                    $("#company_name").attr("readonly", "readonly");
                }
                else {
                    layer.alert('信息获取失败，请重试！', { icon: 5 });
                }
            }, true, "", "get");
        }

        //图片点击跳转
        function imgzoom(obj) {
            var img = document.getElementById(obj).src
            if (!!img) {
                onclick = window.open(img)
            }
        }

        function getprovince(id, obj, sid) {
            ajax("/tools/GetPrivoceList/" + id, {}, function (data) {
                var ui = "<option value=''>请选择</option>";
                $.each(data, function (row, value) {
                    ui += "<option value='" + value.id + "'>" + value.name + "</option>";
                })
                $(obj).html(ui);
                $(obj).show();
                if (sid != undefined && sid != '')
                    $(obj).val(sid);
            })
        }

    </script>
}

